<?php
/**
@version 1.0: mod_ltc_weather
Author: Shape 5 - Professional Template Community
Edited: Chuvan
Free extension available for download at www.shape5.com
*/


// no direct access

$zip = $_GET['zip'];
$scale  = $_GET['scale'];

?>

	
<?php
$br = strtolower($_SERVER['HTTP_USER_AGENT']); // what browser.
if(ereg("msie 6", $br)) {
$iss_ie6 = "yes";
} 
else {
$iss_ie6 = "no";
}
?>

<?php
	
	error_reporting(0); 
	
	include('weather.class.php');
	$ltc_head=" <html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />";
	$ltc_head.="<style> body {\n	background: #FFFFFF;\n	color: #000000;\n	font-size:14px; font-family: Arial, sans-serif;\n } </style>\n</head>";
	$ltc_head.="\n";
	$ltc_select="";
	$ltc_body="";
	$ltc_bottom="</body></html>";
	
	
			

		if ($scale == "f") {
		
		$ret = weather($zip,  ($_GET['u'] == 'f'));
		}

		if ($scale == "c") {
		
		$ret = weather($zip,  ($_GET['u'] = 'c'));
		}
			
				
			
			foreach($ret as $day) {
			if(isset($day['temp'])) {	
			
			switch ($day['text']) {
				case "Mostly Cloudy":
					$day['text'] = "Nhiều mây";
					break;
				case "Mist":
					$day['text'] = "Sương mù";
					break;
				case "Fair":
					$day['text'] = "Trời đẹp";
					break;
				case "Thunderstorm":
					$day['text'] = "Mưa giông";
					break;
				case "Thunder":
					$day['text'] = "Có sấm";
					break;
				case "Sunny":
					$day['text'] = "Trời nắng";
					break;
				case "Clear":
					$day['text'] = "Trời quang đãng";
					break;
				case "Partly Cloudy":
					$day['text'] = "Mây thay đổi";
					break;		
				case "Fog":
					$day['text'] = "Sương mù";
					break;					
				case "Light Rain":
					$day['text'] = "Mưa nhỏ";
					break;					
				case "Cloudy":
					$day['text'] = "Có mây";
					break;	
				case "Rain":
					$day['text'] = "Trời mưa";
					break;
				case "Rain Shower":
					$day['text'] = "Mưa rào";
					break;					
			}			
			
				$ltc_body.= "<div class=\"ltc_weather_padding\" id=\"ltc_weather_box\"><div style=\"float:left;width:100%; background:url(ltc_weather/".$day['image'].") top right no-repeat;\"><strong><font color=\"#2982D6\"> ".$day['text']."</font></strong><div style=\"float:left;font-size:11px;\">";
			
				$ltc_body.= 'Nhiệt độ TB: '.$day['temp'].'<br/>';
				$ltc_body.= 'Gió '.$day['wind'].'<br/>';
				$ltc_body.= 'Độ ẩm: '.$day['humidity'].'<br/>';
				//$ltc_body.= 'Visibility: '.$day['visibility'].'<br/>';
				//$ltc_body.= 'pressure: '.$day['pressure'].'<br/>';
				$ltc_body.= 'Mặt trời lên: '.$day['sunrise'].'<br/>';
				$ltc_body.= 'Mặt trời lặn: '.$day['sunset'];		
				$ltc_body.= "</div></div><div style=\"clear: both;\"></div></div>";
				
				}
		}	
				
				
		
	
	
	echo $ltc_head.$ltc_select;
	echo $ltc_body;
	echo $ltc_bottom;
?>




